<template>

  <div v-if="visible"
       class='choose-file-container'>
    <el-dialog @close="dialogClose"
               :visible.sync="visible"
               title="选择文件"
               width="80%">
      <ProjectFile mode="choose"
                   :projectId="projectId"
                   :choosedList.sync="choosedFileList"
                   ref="projectFile"></ProjectFile>
      <div slot="footer"
           class="dialog-footer">
        <el-button @click="dialogClose">取消</el-button>
        <el-button @click="getChoosedFile"
                   type="primary">确 定</el-button>
      </div>
    </el-dialog>
  </div>

</template>
<script>
import ProjectFile from '@/pages/ProjectManage/ProjectFile'
export default {
  data () {
    return {
      visible: false,
      choosedFileList: []
    }
  },
  components: {
    ProjectFile
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    callback: {
      type: Function
    },
    projectId: {
      type: Number,
      default: 0
    }
  },
  watch: {
    dialogVisible (newval) {
      this.visible = newval
    }
  },
  methods: {
    dialogClose () {
      this.$emit('update:dialogVisible', false)
    },
    getChoosedFile () {
      // let selection = this.$refs.projectFile.$refs.fileTable.selection
      let selection = this.choosedFileList
      this.$emit('callback', selection)
      // console.log(selection, 'get choosed file')
    }
  },
  created () {
  },
  mounted () {
  }
}
</script>
<style scoped lang='scss'>
.choose-file-container {
}
</style>
